﻿using System.Collections.Generic;
using System.Linq;
using HinduShop.Domain.Models;

namespace HinduShop.UI.ViewModels.Cart
{
    public class CartSummaryViewModel
    {
        private readonly List<CartLine> lineCollection = new List<CartLine>();

        public CartSummaryViewModel(Domain.Models.Cart cart)
        {
            lineCollection = cart.Lines.ToList();
        }

        public decimal ComputeTotalValue()
        {
            return lineCollection.Sum(e => e.Product.Price * e.Quantity);
        }

        public IEnumerable<CartLine> Lines
        {
            get { return lineCollection; }
        }
    }
}